<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: xiangyinjie
  Date: 2021/5/10
  Time: 19:11
  To change this template use File | Settings | File Templates.
--%>

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<style>
    #treatment {
        position: relative;
        width: 450px;
        height: 180px;
        margin: auto;
        z-index: 30;
        background-color: #f6f6f6;
        display: none;
        margin-top: -235px;
    }

    #err {
        font-size: 40px;
        float: right;
        margin: 0px 10px;
        user-select: none;
    }

    .layui-inline {
        margin-top: 10px;
        margin-left: 40%;
    }


</style>
<head>
    <meta charset="utf-8">
    <title>Title</title>
    <%
        //获取项目的根路径
        String path = request.getContextPath();
        String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
    %>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="<%=basePath%>layui-v2.6.5/layui/css/layui.css" media="all">
    <link rel="stylesheet" type="text/css" href="<%=basePath%>sweetalert.css">
    <script type="text/javascript" src="<%=basePath%>sweetalert-dev.js"></script>
</head>
<body>
<form method="post" action="<%=basePath%>QueuePageServlet">
    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 50px;">
        <legend>转诊</legend>
    </fieldset>
    <div class="layui-inline">
        <div class="layui-input-inline ">
            <input type="text" name="id" class="layui-input">
        </div>
    </div>
    <button type="submit" class="layui-btn" style="background-color:#009f95;margin-top: 10px">搜索</button>
    <table class="layui-table" lay-skin="line">
        <colgroup>
            <col width="150">
            <col width="150">
            <col width="200">
            <col>
        </colgroup>
        <thead>
        <tr>
            <th>编号</th>
            <th>名字</th>
            <th>医生编号</th>
            <th>看诊时间</th>
            <th>状态</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        <c:forEach items="${requestScope.pagequeue.list}" var="queue">
            <tr>

                <td>${queue.patientId}</td>
                <td>${queue.patientName}</td>
                <td>${queue.doctorid}</td>
                <td>${queue.time}</td>
                <td>
                    <c:choose>
                        <c:when test="${queue.state==0}">
                            未缴费
                        </c:when>
                        <c:otherwise>
                            已缴费
                        </c:otherwise>
                    </c:choose>
                </td>
                <td><a href="#" class="deskilling">
                    <button type="button" class="layui-btn layui-btn-xs layui-btn-normal"
                            style="background-color:#009f95; width: 40px;height: 25px;">转诊
                    </button>
                </a></td>
            </tr>
        </c:forEach>
        </tbody>
    </table>
    <c:if test="${requestScope.pagequeue.currentPage!=1}">
        <a href="<%=basePath%>QueuePageServlet?curr=1&id=${requestScope.patientId}">
            <button type="button" class="layui-btn layui-btn-sm">首页</button>
        </a>
    </c:if>
    <c:if test="${requestScope.pagequeue.currentPage>1}">
        <a href="<%=basePath%>QueuePageServlet?curr=${requestScope.pagequeue.currentPage-1}&id=${requestScope.patientId}">
            <button type="button" class="layui-btn layui-btn-sm">上一页</button>
        </a>
    </c:if>
    <button type="button" class="layui-btn layui-btn-sm"
            style="margin-right: 5px">${requestScope.pagequeue.currentPage}</button>
    <span style="font-size: 30px;position: absolute">/ </span>
    <button type="button" class="layui-btn layui-btn-sm"
            style="margin-left: 10px">${requestScope.pagequeue.totalPage}</button>
    <c:if test="${requestScope.pagequeue.currentPage<requestScope.pagequeue.totalPage}">
        <a href="<%=basePath%>QueuePageServlet?curr=${requestScope.pagequeue.currentPage+1}&id=${requestScope.patientId}">
            <button type="button" class="layui-btn layui-btn-sm">下一页</button>
        </a>
    </c:if>
    <c:if test="${requestScope.pagequeue.currentPage!=requestScope.pagequeue.totalPage}">
        <a href="<%=basePath%>QueuePageServlet?curr=${requestScope.pagequeue.totalPage}&id=${requestScope.patientId}">
            <button type="button" class="layui-btn layui-btn-sm">尾页</button>
        </a>
    </c:if>
    </div>
</form>

<div id="treatment">
    <div id="err">×</div>
    <form class="layui-form" action="">

        <p style="padding-left: 80px;padding-top: 30px;">用户编号：<span></span>用户姓名：<span></span></p>

        <%--        <div class="layui-inline">--%>
        <%--            <label class="layui-form-label">转诊科室</label>--%>
        <%--            <div class="layui-input-inline">--%>
        <%--                <select name="modules" lay-verify="required" lay-search="">--%>
        <%--                    <option selected>请选择科室</option>--%>
        <%--                    <c:forEach items="${requestScope.kelist}" var="list">--%>
        <%--                        <option>${list.dtname}</option>--%>
        <%--                    </c:forEach>--%>

        <%--                </select>--%>
        <%--            </div>--%>
        <%--        </div>--%>

        <div class="layui-form-item" style="margin: 20px 40px;">
            <label class="layui-form-label">转诊科室</label>
            <div class="layui-input-inline">
                <select name="modules" lay-verify="required" lay-search="">
                    <option selected>请选择科室</option>
                    <c:forEach items="${requestScope.kelist}" var="list">
                        <option>${list.dtname}</option>
                    </c:forEach>
                </select>
            </div>
        </div>

    </form>
    <button type="button" id="dianji" class="layui-btn" style="width: 120px;margin-left: 190px;margin-top: 10px">确定
    </button>
</div>

<script src="<%=basePath%>layui-v2.6.5/layui/layui.js" charset="utf-8"></script>
<script type="text/javascript" src="<%=basePath%>jquery/jquery-1.12.4.js"></script>
<script type="text/javascript">

    $(document).ready(function () {

        $(".deskilling").click(function () {
            var $id = $(this).parent().parent().children("td:eq(0)").text();
            var $name = $(this).parent().parent().children("td:eq(1)").text();
            $("#treatment p span:eq(0)").text($id);
            $("#treatment p span:eq(0)").css({"margin-right": "30px"})
            $("#treatment p span:eq(1)").text($name);
            $("#treatment").show();
        });
        $("#err").click(function () {
            $("#treatment").hide();
        })
        $("#dianji").click(function () {
            let $id = $("#treatment p span:eq(0)").text();
            let $quiz1 = $("select[name='modules']  option:selected").val();
            if ($quiz1 === "请选择科室") {
                swal({
                    title: "<img src='frontdesk/错误.png' style='width: 40px;height: 40px;margin: 20px;'><small>请选择科室</small>!",
                    html: true
                });
                return;
            }
            $.ajax({
                async: false,
                url: "<%=basePath%>QueueTreatmentServlet",
                type: "post",
                data: {
                    quiz1: $quiz1,
                    id: $id
                },
                dataType: "JSON",
                success: function (data) {
                    if (data) {
                        swal({
                                title: "<small>转诊成功</small>",
                                html: true,
                            },
                            function () {
                                window.location.reload();
                            });
                    }
                }
            })
        });
    });


</script>
</body>
</html>
